package com.design.state.football2;

// 状态接口
interface FootballPlayerState {
    void play(FootballPlayer player);
}

// 具体状态类：梦游状态
class DaydreamingState implements FootballPlayerState {
    public void play(FootballPlayer player) {
        System.out.println("球员处于梦游状态，思考人生...");
        // 根据一定条件切换到亢奋状态
        player.setState(new ExcitedState());
    }
}

// 具体状态类：亢奋状态
class ExcitedState implements FootballPlayerState {
    public void play(FootballPlayer player) {
        System.out.println("球员处于亢奋状态，头顶脚踢，努力进球！");
        // 根据一定条件切换到体力透支状态
        player.setState(new ExhaustedState());
    }
}

// 具体状态类：体力透支状态
class ExhaustedState implements FootballPlayerState {
    public void play(FootballPlayer player) {
        System.out.println("球员处于体力透支状态，动作变形，射门软绵无力...");
        // 根据一定条件切换到梦游状态
        player.setState(new DaydreamingState());
    }
}

// 环境类：足球比赛中的球员
class FootballPlayer {
    private FootballPlayerState currentState;

    public FootballPlayer() {
        // 初始化状态为梦游状态
        setState(new DaydreamingState());
    }

    public void setState(FootballPlayerState state) {
        this.currentState = state;
    }

    public void play() {
        currentState.play(this);
    }
}
